package com.genius.reservation.common.rabbitmq;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.genius.reservation.reservation.entity.ReservationInformation;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import java.util.HashMap;

@Component
public class RabbitService {
    @Autowired
            @Lazy
    RabbitTemplate rabbitTemplate;

    public void ToReceiver(RabbitMessageEntity o){
        String s = JSONObject.toJSONString(o, SerializerFeature.WriteMapNullValue);
        rabbitTemplate.convertAndSend(RabbitConfig.RECEIVER,s);
    }

    public void ToReceiverManager(RabbitMessageEntity o){
        String s = JSONObject.toJSONString(o, SerializerFeature.WriteMapNullValue);
        rabbitTemplate.convertAndSend(RabbitConfig.RECEIVE_MANAGER,s);
    }


    public void ToDriver(RabbitMessageEntity o){
        String s = JSONObject.toJSONString(o);
        rabbitTemplate.convertAndSend(RabbitConfig.DRIVER,s);
    }

    public void ToSupplier(RabbitMessageEntity o){
        String s = JSONObject.toJSONString(o);
        rabbitTemplate.convertAndSend(RabbitConfig.SUPPLIER,s);
    }

}
